import numpy as np
# pip install matplotlib
import matplotlib.pyplot as plt

Δt = 0.001
A = np.zeros((2, 5000), dtype=np.float32)  # 5000个数
t = [i*0.001 for i in range(0, 5000, 1)]  # 5000个数
Tarray = [0.5, 1]  # 时间常数

for j in range(0, 2, 1):
    K = 1
    T = Tarray[j]  # 时间常数
    y0 = 0
    yk_1 = y0
    r = 0  # 设定值
    for i in range(0, 5000):
        if (i == 999):
            r = 1
        yk = (yk_1+r*Δt/T)/(1+K*Δt/T)
        yk_1 = yk
        A[j][i] = yk

plt.title("Simulation")  # 括号当中输入标题的名称
plt.plot(t, A[0], label="T = 0.5")
plt.plot(t, A[1], label="T = 1")
plt.legend(loc='best')  # 图列位置，可选best，center等
plt.show()
